import axios from 'axios'



const request = axios.create({
  baseURL: '/v1/api',
  timeout: 5000
})


function useAuthMiddleware(request) {
  request.interceptors.request.use((config) => {
    config.headers = {
      ...config.headers,
      auth: sessionStorage.getItem('auth')
    }

    return config
  }, () => {

  })
}


function useLocalMiddleware(request) {
  request.interceptors.request.use((config) => {
    config.headers = {
      ...config.headers,
      local: sessionStorage.getItem('local') || 'zh-cn'
    }

    return config
  }, (error) => {

  })
}

useAuthMiddleware(request)
useLocalMiddleware(request)



export default request


